package com.jlpay.openapi.demo.trans.common;

import com.jlpay.open.jlpay.sdk.java.model.trans.common.request.PreAuthCloseRequest;
import com.jlpay.open.jlpay.sdk.java.model.trans.common.response.PreAuthCloseResponse;
import com.jlpay.open.jlpay.sdk.java.utils.json.JsonUtils;
import com.jlpay.openapi.demo.JlpayOpenApiService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 *
 * @author dengwenning
 * @since 2024/9/23
 **/
public class PreAuthCloseService {
    private static final Logger LOGGER = LoggerFactory.getLogger(PreAuthCloseService.class);

    public static void main(String[] args) {
        PreAuthCloseRequest preAuthCloseRequest = buildPreAuthCloseRequest();
        PreAuthCloseResponse preAuthCloseResponse = JlpayOpenApiService.openMerchService()
                .post(preAuthCloseRequest, PreAuthCloseResponse.class);
        LOGGER.info("预授权关单响应:{}", JsonUtils.toString(preAuthCloseResponse));
    }

    private static PreAuthCloseRequest buildPreAuthCloseRequest() {
        PreAuthCloseRequest preAuthCloseRequest = new PreAuthCloseRequest();

        preAuthCloseRequest.setMchId("849584358120018");
        preAuthCloseRequest.setTermNo("60131234");
        preAuthCloseRequest.setPayType("wxpay");
        preAuthCloseRequest.setOutTradeNo("ld201911023465529");
        preAuthCloseRequest.setOriOutTradeNo("ld2019102216465525");
        preAuthCloseRequest.setOriTransactionId("80011557201909171853011568");
        preAuthCloseRequest.setGuaranteeAuthCode("134965710109584780");
        preAuthCloseRequest.setTotalFee("1");
        preAuthCloseRequest.setRemark("该订单物流请走顺丰快递");
        preAuthCloseRequest.setDeviceInfo("N50007A8890");
        preAuthCloseRequest.setMchCreateIp("123.12.12.123");
        preAuthCloseRequest.setTransAddress("深圳市南山区科技二路10号");
        preAuthCloseRequest.setAreaCode("4403");
        preAuthCloseRequest.setLongitude("116.078631");
        preAuthCloseRequest.setLatitude("39.71274");

        return preAuthCloseRequest;
    }
}
